<template>
  <div id="">
    <headerbox :headerTitle="'详情'" :hasBack='true'></headerbox>
    <events :eventItem="eventItem"></events>
    <div class="p10 bgWhite">
      <noneList v-if="matchMsgList.length==0" :noneTxt="'暂无评论'"></noneList>
      <messageCon v-else v-for="matchMsg in matchMsgList" :key="matchMsg.key" :msgCon="matchMsg"></messageCon>
    </div>
    <replyButtom :replyTip="'说点什么吧...'" :matchId="matchId" :replyId="' '"></replyButtom>
  </div>
</template>
<script>
import events from '@/pages/events/eventItem/eventItem';
import {matchInfomation,matchCommentList} from '@/utils/ajaxRequest.js';
export default {
  name: "",
  data: () => ({
    matchMsgList:[],
    matchId:'',
    eventItem: '',
    xlyd_loginInfo:'',
  }),
  components: {
    events,
    messageCon:()=>import('./template/messageCon'),
    replyButtom:()=>import('./template/replyButtom'),
    noneList:()=>import('@/components/noneList/noneList'),
  },
  methods: {
    // 获取赛事详情
    getMatchInfo() {
      let self = this;
      let infoParam = {
        matchId:self.matchId,
        token:self.xlyd_loginInfo.token,
      }
      matchInfomation(infoParam).then(res=>{
        console.log(res);
        if(res) {
          let eventItem = res.data.result;
          self.eventItem = eventItem;
        }
      });
    },
    // 获取赛事评论列表
    getMatchCommentList() {
      let self = this;
      let infoParam = {
        matchId:self.matchId,
        token:self.xlyd_loginInfo.token,
      }
      matchCommentList(infoParam).then(res=>{
        console.log(res);
        if(res) {
          self.matchMsgList = res.data.result;
        }
      });
    }
  },
  mounted() {
    //do something after mounting vue instance
    let self = this;
    let matchId = self.$route.query.matchId;
    self.matchId = matchId;
    let xlyd_loginInfo = JSON.parse(window.localStorage.getItem('xlyd_loginInfo'));
    self.xlyd_loginInfo = xlyd_loginInfo;
    self.getMatchInfo();
    self.getMatchCommentList();
  }
}
</script>
<style lang="scss" scoped>
</style>
